function BytesToString(bytes, charset)
{
	var text;

	var objstream = WScript.CreateObject("adodb.stream");
	objstream.Type = 1;
	objstream.Mode = 3;
	objstream.Open();
	objstream.Write(bytes);
	objstream.Position = 0;
	objstream.Type = 2;
	objstream.Charset = charset;
	text = objstream.ReadText();
	objstream.Close();
	objstream = null;

	return text;
}

function HttpInit()
{
	http = WScript.CreateObject("WinHttp.WinHttpRequest.5.1");
	if (http != null)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function HttpRelease()
{
	if (http != null)
	{
		http.Close();
		http = null;
	}
}

function HttpGetPage(url, encode)
{
	var page = "";
	if (http != null)
	{
		http.Open("GET", url);
		http.Send();
		page = BytesToString(http.responseBody, encode)
	}

	return page;
}

var http;
